<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:v="http://corejsf.com/validator">

<f:view>
	<f:loadBundle var="text" basename="#{userList.bundleName}" />
	<head>
	<title>#{text['menu.product.add']}</title>
	<meta name="heading" content="#{text['menu.product.add']}" />
	<meta name="menu" content="AdminMenu" />
	</head>
	<body id="createNewProduct">
	<h:form id="addNewProduct" enctype="multipart/form-data">
		<h:inputHidden value="#{productForm.product.id}" id="id"/>
		<h:panelGrid>
			<h:outputLabel for="productName" value="#{text['menu.product.name']}"
				styleClass="desc" />
			<t:message for="productName" errorStyle="color:red" />
			<h:inputText requiredMessage="'Product name' is required field"
				value="#{productForm.product.name}" id="productName" required="true"
				styleClass="text large">
				<v:commonsValidator type="required"></v:commonsValidator>
			</h:inputText>

			<h:outputText value="Price"></h:outputText>


			<t:htmlTag value="table">
				<t:htmlTag value="tr">
					<t:htmlTag value="td" style="width:30px;">
						<h:outputLabel for="productAliquot"
							value="#{text['menu.product.aliquot']}" styleClass="desc" />
						<t:message for="productAliquot" errorStyle="color:red" />
						<h:inputText value="#{productForm.aliquot}" id="productAliquot"
							required="true" styleClass="width:30px;">
							<v:commonsValidator type="mask" mask="^[0-9]*$" message="#{text['menu.product.aliquot.error']}"/>
						</h:inputText>
					</t:htmlTag>

					<t:htmlTag value="td" style="width:30px;">
						<h:outputLabel for="productFraction"
							value="#{text['menu.product.fraction']}" styleClass="desc" />
						<t:message for="productFraction" errorStyle="color:red" />
						<h:inputText value="#{productForm.fraction}" id="productFraction"
							required="true" styleClass="width:30px;">
							<v:commonsValidator type="mask" mask="^[0-9]*$" message="#{text['menu.product.fraction.error']}"/>
						</h:inputText>
					</t:htmlTag>
				</t:htmlTag>
			</t:htmlTag>

			<h:outputLabel for="productCurrency"
				value="#{text['menu.product.currency']}" styleClass="desc" />
			<t:message for="productCurrency" errorStyle="color:red" />
			<h:inputText requiredMessage="'Currency' is required field"
				value="#{productForm.product.currency}" id="productCurrency"
				required="true" styleClass="text large">
				<v:commonsValidator type="required"></v:commonsValidator>
			</h:inputText>

			<h:outputLabel for="productURL" value="#{text['menu.product.URL']}"
				styleClass="desc" />
			<t:message for="productURL" errorStyle="color:red" />
			<h:inputText requiredMessage="'URL' is required field"
				value="#{productForm.product.URL}" id="productURL" required="true"
				styleClass="text large">
				<v:commonsValidator type="required"></v:commonsValidator>
			</h:inputText>

			<h:outputLabel for="productDescription"
				value="#{text['menu.product.description']}" styleClass="desc" />
			<h:inputTextarea cols="5" rows="5"
				value="#{productForm.product.description}" id="productDescription"
				styleClass="text large" />

			<h:outputLabel styleClass="desc" for="file"
				value="#{text['menu.product.image']}" />
			<t:message for="file" styleClass="fieldError" />
			<t:inputFileUpload id="file" value="#{productForm.file}"
				storage="file" required="false" styleClass="file medium" />

			<h:outputLabel styleClass="desc" for="selectedShop"
				value="#{text['menu.product.shop']}" />
			<h:selectOneMenu value="#{productForm.selectedShopId}"
				id="selectedShop" required="true" styleClass="select" binding="#{productForm.selectItem}">
				<f:selectItems value="#{productForm.shopList}" />
			</h:selectOneMenu>

			<h:outputLabel styleClass="desc" for="selectedCategory"
				value="#{text['menu.product.category']}" />
			<h:selectOneMenu value="#{productForm.selectedCategoryId}"
				id="selectedCategory" required="true" styleClass="select" binding="#{productForm.selectFractionItem}">
				<f:selectItems value="#{productForm.categoryList}" />
			</h:selectOneMenu>

			<h:panelGroup styleClass="buttonBar bottom">
				<h:commandButton value="#{text['button.save']}"
					action="#{productForm.create}" id="saveProduct" styleClass="button" />
				<h:commandButton value="#{text['button.cancel']}" action="cancel"
					immediate="true" id="cancel" styleClass="button"
					onclick="bCancel=true" />
				<h:commandButton value="#{text['button.delete']}" action="#{productForm.delete}"
					id="delete" styleClass="button"/>						
			</h:panelGroup>
		</h:panelGrid>
	</h:form>
	</body>
</f:view>
</html>
